package com.mediacloud.app.newsmodule.fragment.ugc

import android.view.View
import android.widget.ImageView
import android.widget.TextView
import com.mediacloud.app.assembly.util.loadRound
import com.mediacloud.app.assembly.views.CornerBlurView
import com.mediacloud.app.model.news.ArticleItem
import com.mediacloud.app.newsmodule.R
import com.mediacloud.app.newsmodule.adaptor.component.BaseViewHolder

class LiteAvItemHolder(view: View) : BaseViewHolder(view) {
    val logo: CornerBlurView = view.findViewById(R.id.logo)
    val duration: TextView = view.findViewById(R.id.duration)
    val like: TextView = view.findViewById(R.id.like)
    val title: TextView = view.findViewById(R.id.title)
    val avatar: ImageView = view.findViewById(R.id.avatar)
    val author: TextView = view.findViewById(R.id.author)
    val catalog: TextView = view.findViewById(R.id.catalog)

    fun setViewHolderData(item: ArticleItem) {
        logo.load(item.tipImage, true)
        duration.text = item.duration
        like.text = "${item.favorCount_format}赞"
        title.text = item.title
        avatar.loadRound(item.avatar)
        author.text = item.tipPerson
        if (item.catalogName.isNullOrEmpty()) {
            catalog.visibility = View.GONE
        } else {
            catalog.visibility = View.VISIBLE
            catalog.text = "#${item.catalogName}"
        }
    }
}